#!/bin/bash

#上传了很多次都没有得到成功,一次又一次测试后终于搞定了。
#运行测试通过、完美实现文件备份

#get the dir for tar
saveDir=$1
#setting the save dir
tarDir=${HOME:-}/TarDir
#if the dir is not exist.create it
if [ ! -d $tarDir ];
then
	mkdir TarDir
fi
#use the time now for it`s name
set `date`
thisTime=$1$2$3

#build a new fileName
tarFile=$tarDir/$thisTime.tar

if [ -f  $tarFile ];
then
	echo "your tarFile is exist now, continue tomorrow!";
else
	
	#back up when the dir is exist
	if [ -d $saveDir ];
	then 
		tar -cvf $tarFile $saveDir/*
	else
		echo "your input dir is not exist!";
	fi
fi
echo "complete!";

